

from __future__ import division

#>>> from sympy import *
#>>> x = Symbol('x')
#>>> diff(sin(x), x)
#cos(x)
#>>> diff(sin(2*x), x)
#2*cos(2*x)
#
#>>> diff(tan(x), x)
#1 + tan(x)**2

from sympy import *
A = Symbol('A')
A0 = Symbol('A0')
A1 = Symbol('A1')
A2 = Symbol('A2')
m0 = Symbol('m0')
m1 = Symbol('m1')
t = Symbol('t')
w = Symbol('w')
w0 = Symbol('w0')
w1 = Symbol('w1')
w2 = Symbol('w2')
p = Symbol('p')



print 'C0 smooth'
eq = A * cos(t * w + p)
print 'eq\t', eq
print
print 'dA\t', diff(eq, A)
print 'dw\t', diff(eq, w)
print 'dp\t', diff(eq, p)

print
print 'C1 smooth'
eq = ((1 - t) * A0 + t * A1) * cos(t * w + p)
print 'eq\t', eq
print
print 'dA0\t', diff(eq, A0)
print 'dA1\t', diff(eq, A1)
print 'dw\t', diff(eq, w)
print 'dp\t', diff(eq, p)

print
print 'C3 smooth'
eq = ((2 * t ** 3 - 3 * t ** 2 + 1) * A0 + (t ** 3 - 2 * t ** 2 + t) * m0 + (-2 * t ** 3 + 3 * t ** 2) * A1 + (t ** 3 - t ** 2) * m1) * cos(t * w + p)
print 'eq\t', eq
print
print 'dA0\t', diff(eq, A0)
print 'dA1\t', diff(eq, A1)
print 'dm0\t', diff(eq, m0)
print 'dm1\t', diff(eq, m1)
print 'dw\t', diff(eq, w)
print 'dp\t', diff(eq, p)

print
print 'test1'
eq = (exp(A0 + t * A1 + t ** 2 * A2)) * cos(t * w + p)
print 'eq\t', eq
print
print 'dA0\t', diff(eq, A0)
print 'dA1\t', diff(eq, A1)
print 'dA2\t', diff(eq, A2)
print 'dw\t', diff(eq, w)
print 'dp\t', diff(eq, p)

print
print 'test2'
eq = (exp(A0 + t * A1 + t ** 2 * A2)) * cos(exp(w0+w1*t+w2*t**2))
print 'eq\t', latex(eq)
print
print 'dA0\t', latex(diff(eq, A0))
print 'dA1\t', latex(diff(eq, A1))
print 'dA2\t', latex(diff(eq, A2))
print 'dw0\t', latex(diff(eq, w0))
print 'dw1\t', latex(diff(eq, w1))
print 'dw2\t', latex(diff(eq, w2))

print
print 'test3'
eq = (A0 + t * A1 + t**2 * A2) * cos(w0+w1*t+w2*t**2)
print 'eq\t', latex(eq)
print
print 'dA0\t', latex(diff(eq, A0))
print 'dA1\t', latex(diff(eq, A1))
print 'dA2\t', latex(diff(eq, A2))
print 'dw0\t', latex(diff(eq, w0))
print 'dw1\t', latex(diff(eq, w1))
print 'dw2\t', latex(diff(eq, w2))


print cse([diff(eq,A0),diff(eq,A1),diff(eq,A2),diff(eq,w0),diff(eq,w1),diff(eq,w2)])
